/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package facilitator;

import core.CalculationException;
import core.DmuList;
import core.Optimization;
import core.Optimizer;
import core.PdmOptimization;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Niki
 */
public class HeuristikSolver extends Solver{
        private int[] heuristikDirections;

        public HeuristikSolver(DmuList dmuList, int objectiveDmu, double[] urmWeights){
            this.dmuList = dmuList;
            this.objectiveDmu = objectiveDmu;
            this.urmWeights = urmWeights;
            try {
                Optimization deaOpt = new Optimization(dmuList, objectiveDmu);
                Optimizer.calculateDea(deaOpt);
                PdmOptimization pdmOpt = new PdmOptimization(dmuList,objectiveDmu, 0, urmWeights, deaOpt);
                Optimizer.calculatePdm(pdmOpt);
                this.heuristikDirections = pdmOpt.getOptimizationDirections();
                //get heuristik directions
            } catch (CalculationException ex) {
                Logger.getLogger(Bisection_1.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        public PdmOptimization getOptimization(double alpha) {
            //Util.log(cnt++ + " Optimization " + alpha);
            try {
                PdmOptimization opt = new PdmOptimization(this.dmuList, this.objectiveDmu, alpha, this.urmWeights, this.heuristikDirections);
                Optimizer.calculatePdm(opt);
                return opt;
            } catch (CalculationException ex) {
                Logger.getLogger(Bisection_1.class.getName()).log(Level.SEVERE, null, ex);
                return null;
            }
        }
}
